import { reqGetSearchInfo } from "@/api"
//search模块的小仓库
const state = {
    searchList: {}
}
//计算搜索列表数据
const mutations = {
    GETSEARCHLIST(state, searchList) {
        state.searchList = searchList;
    }
}
const actions = {
    //获取搜索模块数据
    async getSearchList({ commit }, params = {}) {
        let result = await reqGetSearchInfo(params);
        if (result.code == 200) {
            commit("GETSEARCHLIST", result.data)
        }
    }
}
//计算属性,主要简化仓库的数据
const getters = {
    goodsList(state) {
        //假如网络不给力，goodsList返回的应该是一个空数组
        return state.searchList.goodsList || []
    },
    trademarkList(state) {
        return state.searchList.trademarkList
    },
    attrsList(state) {
        return state.searchList.attrsList
    }
}
export default {
    state,
    mutations,
    actions,
    getters
}